package com.anosine.gpsl.android.util;

import com.anosine.gpsl.android.entity.Login;
import com.anosine.gpsl.android.util.cache.BaseModelProxy;


/**
 * @Title: UserInfoProxy
 * @Package com.anosine.gpsl.android.util
 * @Description: 保存用户基本数据
 * @author: sunny
 * @date: 2015-11-23
 * @version V1.0
 */
public class UserInfoProxy extends BaseModelProxy<String, Login> {
	//proxy 代理
    private static final String TAG_USER_INFO_CACHE = "MyLoginInfoCache_New_1";
    private Login mLoginInfo ;
    /**
     * 方法名：UserInfoProxy()
     * 功能：初始化
     * 参数：无
     * */
    public UserInfoProxy() {
        super(TAG_USER_INFO_CACHE);
    }
    
    private static UserInfoProxy sUserInfoProxy = new UserInfoProxy();

    public static UserInfoProxy getInstance() {
        return sUserInfoProxy;
    }

    @Override
    protected String getKey(String... args) {
        return "UserInfoCache_Key_";
    }

    public Login getLoginInfo() {
        if (mLoginInfo == null) {
            mLoginInfo = hitLocal();
        }

        return mLoginInfo;
    }

    public boolean isLoginSuccess() {
        if (mLoginInfo == null) {
            getLoginInfo();
        }
        return mLoginInfo != null ?  mLoginInfo.isLoginAuto : false;
       // return mLoginInfo != null ? "msg_login_suucess".equals(mLoginInfo.message) && mLoginInfo.isLoginAuto : false;
    }

    public Login setLoginUserInfo(Login info) {
        putLocal(info);
        mLoginInfo = info;
        return info;
    }

}
